<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>


<html>
  <head>
    <title>添加维修中心</title>
    <%@ include file="../common/base.jsp" %>
   
    <script type="text/javascript">

    //手机号码
    function phoneBlur(focusFlag){
    	var phone = $("#phone").val();
    	$("#phoneZhu").html("");
    	$("#phones").hide();
		$("#phoneZhu").hide();				
		var reg = /^1\d{10}$/;  //定义正则表达式				
		if(phone ==null || !reg.test(phone)){
			$("#phoneZhu").show();
			$("#phoneZhu").append("输入有误,手机号码由11位数字组成");
			if(focusFlag){
				locationFocus("phone");
			}
			return false;
		}else{
			$("#phones").show();
			return true;
		}
    }

    
    function addStationSubmit(){
    	if(!validateContentNotNull('repairName',1,30,'维修中心名称',true)){
    		return false;
    	}
    	if(!phoneBlur(true)){
    		return false;
    	}

        $.ajax({
            cache: true,
            type: "POST",
            url:"${pageContext.request.contextPath}/repair/saveOrUpdate",
            data:$('#tAicheRepairDTO').serialize(),// 你的formid
            async: false,
            error: function(request) {
                alert("Connection error");
            },
            success: function(data) {
                if(data.errorCode == 0){
                    prompt.alert("操作成功");
                    setTimeout(function(){
                        window.location.href="${pageContext.request.contextPath}/repair/showRepair";
                    },2000);

                }
            }
        });
    }

        function changeParentId(type){
            var parentId="-1"
            if(type ==1){
                parentId = $("#province").val();
            }else if(type ==2){
                parentId = $("#city").val();
            }

            $.ajax({
                type: "POST",
                url: "${pageContext.request.contextPath}/district/queryDistrict",
                dataType:"json",
                data: {
                    parentId:parentId
                },
                success: function(data){
                    if(data.errorCode == 0){
                        var jo = eval(data.districtList);
                        var html="<option value=\"-1\">全部</option>";
                        for (var i = 0; i < jo.length; i++) {
                            html = html +"<option value='"+jo[i].districtId+"'>"+jo[i].districtName+"</option>"
                        }
                        if(type ==1){
                            $("#city").html(html);
                        }else if(type ==2){
                            $("#area").html(html);
                        }
                    }
                }
            });
        }
    </script>
    
  </head>
  
  <body id="body">
  	<!--head-->
	<div id="head">
		<jsp:include page="../common/head.jsp"></jsp:include>
	</div>
	<!--head end-->
	<!--container-->
	<div id="container">		
		<div id="pageId" style="display: none;">02-02-01</div>
		<!--sidebar-->
		<%@ include file="../common/menu.jsp" %>
		<!--sidebar-->
	    <!--main-->
	    <div class="main" id="mainDiv">
	    	<div class="channel_manage">
		    	<div class="location" style="background-position:22px -29px;">
					平台管理<span>&gt;</span>修理中心管理<span>&gt;</span>修理信息管理<span>&gt;</span>添加修理中心
		        </div>
		        <form method="post" id="tAicheRepairDTO" enctype="multipart/form-data">
		        <!--content-->
		        <div class="content">   	
		            <div class="inputInfoList3">
		                <ul class="recharge_list" style="width:600;">
		                 	<li>
		                        <label>维修中心名称</label>
								<input type="text" id="repairName"  name="repairName"
									   onFocus="this.style.border = '1px solid #2A7CCF'" onblur="validateContentNotNull('repairName',1,30,'维修中心名称');this.style.border = '1px solid #D5D5D5'" maxlength="10"/>
								<span style="position:absolute;left:76%;top:9px;color:red;" class="red">*</span>
								<i style="display: none;background-position: left center;" id="repairNames" class="s_tips"></i>
								<i style="display: none;background-position: left center;padding-left:28%;" id="repairNameZhu" class="zhu_shi_2"></i>
		                	</li>

		                    <li style="position:relative;">
		                        <label>手机号码</label><input type="text" id="phone" name="phone" onFocus="this.style.border = '1px solid #2A7CCF'"
		                                	onBlur="phoneBlur(); this.style.border = '1px solid #D5D5D5'" >
		                        <span style="position:absolute;left:76%;top:9px;color:red;" class="red">*</span>
		                        <i style="display: none;background-position: left center;" id="phones" class="s_tips"></i>
		                        <i style="display: none;background-position: left center;padding-left:28%;" id="phoneZhu" class="zhu_shi_2"></i>
		                    </li>
							<li>
								<label>所属省市区</label>
								<select id="province" name="province" style="width: 110px;" onchange="changeParentId(1);">
									<option value="-1">全部</option>
									<c:forEach var="item" items="${districtList}" varStatus="vatS">
										<option value="${item.districtId}">${item.districtName}</option>
									</c:forEach>
								</select>
								<select id="city" name="city" style="width: 110px;" onchange="changeParentId(2);">
									<option value="-1">全部</option>
								</select>
								<select id="area" name="area" style="width: 110px;">
									<option value="-1">全部</option>
								</select>
							</li>
							<li style="position:relative;">
								<label>详细地址</label><input type="text" id="address" name="address" onFocus="this.style.border = '1px solid #2A7CCF'"
														  onBlur="this.style.border = '1px solid #D5D5D5'" >
							</li>
							<li style="position:relative;">
								<label>描述</label><textarea type="text" id="remark" name="remark" onFocus="this.style.border = '1px solid #2A7CCF'"
														   onBlur=" this.style.border = '1px solid #D5D5D5'"
											style="width: 390px;height: 100px"></textarea>
							</li>

		                </ul>
		                <div class="button_wrap">
		                	<a href="javascript:void(0);" onClick="addStationSubmit();"  class="bg_green">完成</a>
		                    <input type="reset" value="重置">
		                </div>
		            </div>				
	        	</div>
		        <!--content-->
		        </form>
		        <!--foot-->
				<%@ include file="../common/foot.jsp" %>
		        <!--foot-->
		    </div>
		</div>
	    <!--main-->
	</div>
	<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>

  </body>
</html>
